package heritage.joined;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

public class Application {

	public static void main(String[] args) {
		
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("ophidia"); 
		EntityManager em = emf.createEntityManager(); 
		EntityTransaction tx = em.getTransaction(); 
		tx.begin(); 
		
		Vehicule av1 = new Avion("av1", "B-736", "L'aigle", 4);
		em.persist(av1);
		
		Vehicule b1 = new Bateau("ba1", "F-254", "Le rapide", 7);
		em.persist(b1);
		
		tx.commit();
		
		Avion avion = em.find(Avion.class, "av1");
		System.out.println(avion);
		
		Bateau bateau = em.find(Bateau.class, "ba1");
		System.out.println(bateau);
		
		em.close(); 
		emf.close(); 
	}
}
